<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title; ?></h2>
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'action' => Yii::app()->createUrl($this->route),
        'method' => 'GET',
        'id' => 'searchForm'
    )); ?>
    <ul class="clearfix back_bgf border_3 border_c pr30 pl20 pt20 pb20 height32 fontc_666">
        <li class="fl pt10 pr20 pb10 pl8">
            <span class="pr3">学段代码：</span><input type="text" name="edu_code" value="<?php echo $search['edu_code']; ?>" class="pt6 pr5 pb6 pl5 border_3 border_c fontc_666 w100" />
        </li>
        <li class="fl pt10 pr30 pb10 pl3">
            <span class="pr3">学段名称：</span><input type="text" name="edu_name" value="<?php echo $search['edu_name']; ?>" class="pt6 pr5 pb6 pl5 border_3 border_c fontc_666 w100" />
        </li>
        <!--
        <li class="fl pt10 pr30 pb10">
            <span class="fl pr8">是否生效</span><input type="checkbox" name="is_display"  class="fl mt9" />
        </li>
        -->
        <li class="fr pt10 pb10">
            <input type="submit" value="查询" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
        </li>
    </ul>
    <?php
    $this->endWidget(); ?>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30">
            <input type="button" onclick="add();" value="新增" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor fr" style="margin-right:30px;" />
            <input type="button" value="删除" onclick="delete_all()"  class="fl b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <form>
            <table class="height40">
                <thead class="back_bgf5 fontc_666">
                    <tr>
                    	<th width="40" align="right" class="m_hr_t m_hr_b pr10"><input type="checkbox" class="checkboxs"></th>
                        <th width="95" align="center" class="m_hr_t m_hr_b">学段代码</th>
                        <th width="95" align="center" class="m_hr_t m_hr_b">学段名称</th>
                        <th width="180" align="center" class="m_hr_t m_hr_b">年级名称</th>
                        <th width="65" align="center" class="m_hr_t m_hr_b">是否生效</th>
                        <th width="220" align="center" class="m_hr_t m_hr_b">备注</th>
                        <th width="113" align="center" class="m_hr_t m_hr_b">操作</th>
                    </tr>
                </thead>
                <tbody class="fontc_444">
                    <?php if (!empty($data)): ?>
                        <?php foreach ($data as $value): ?>
                            <tr>
                            	<td align="right" class="m_hr_b pr10"><input type="checkbox" name="deleteAll[]" value="<?php echo $value['edu_id']?>" class="checkbox"></td>
                                <td align="center" class="m_hr_b"><?php echo $value['edu_code']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $value['edu_name']; ?></td>
                                <td align="center" class="m_hr_b">
                                    <?php if (!empty($value['grade_data'])): ?>				
                                        <?php foreach ($value['grade_data'] as $gv): ?>				
                                            <?php echo $gv['grade_name']; ?>&nbsp&nbsp					
                                        <?php endforeach; ?>
                                    <?php else: ?>				
                                        没有年级信息				
                                    <?php endif; ?>
                                </td>		
                                <?php if ($value['disabled'] == 1): ?>
                                    <td align="center" class="m_hr_b">
                                        <input type="checkbox" disabled='' checked="checked" />
                                    </td>
                                <?php else: ?>
                                    <td align="center" class="m_hr_b">
                                        <input type="checkbox" diabled='' />
                                    </td>
                                <?php endif; ?>				
                                <td align="center" class="m_hr_b"  title="<?php echo $value['description'];?>">
                                <?php echo (!empty($value['description'])) ? Func::get_word($value['description'], 25) : $value['description']; ?>
                                </td>				
                                <td align="center" class="m_hr_b">
                                     <a href="<?php echo $this->createUrl('/school/default/grade_list',array('edu_id'=>$value['edu_id']))?>" title="添加学年">
                                    <img src="/themes/default/images/Sipei/plus.png" title="添加学年" class="mr10 cursor">
                                    </a>
                                    <img src="/themes/default/images/Sipei/edit.png" title="编辑" class="mr10 cursor" onclick="update(<?php echo $value['edu_id']; ?>)" />
                                    <img src="/themes/default/images/Sipei/delate.png" title="删除" class="cursor" onclick="set_ok(<?php echo $value['edu_id']; ?>)" />
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td colspan="7"><h1 align="center">暂无数据</h1></td>              
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </form>
        <?php $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl)); ?>
    </div>
</div>
<script>
                function set_ok(edu_id) {
	              
                    $.dialog.confirm('确定删除吗', function() {
       
                        $.get('/school/default/delete_all', {edu_id: edu_id}, function(data) {
                        	 if(data == 1){
            			       	 location.reload();
            			     }else if(data == 3){
            					 $.dialog.alert("请清空年级数据后再进行删除操作");
            					 return false;
            				 }else{
            					 $.dialog.alert("删除失败");
            					 return false;
            				}                           
                        });
                    });
                }
                
            	function delete_all(){
					var aa='';
					$("input[name='deleteAll[]']:checkbox:checked").each(function(){
						aa+=$(this).val()+',';
					});
					if(aa == ''){
						$.dialog.alert("请选择要删除条目");
						return false;
					}
					$.dialog.confirm('确定删除所选数据吗', function() {

						aa+=0;
					
                        $.get('/school/default/delete_all', {edu_id: aa}, function(data) {
	                        	 if(data == 1){
	            			       	 location.reload();
	            			     }else if(data == 3){
	            					 $.dialog.alert("请清空年级数据后再进行删除操作");
	            					 return false;
	            				 }else{
	            					 $.dialog.alert("删除失败");
	            					 return false;
	            				}
                        });
                    });
				}
                function add() {
                    api = $.dialog({
                        id: 'testID2',
                        lock: true,
                        padding: 0,
                        fixed: true,
                        title: "新增",
                        width: 480,
                        height: 360,
                        max: false,
                        min: false
                    });
                    $.get('/school/default/add', function(html) {
                        api.content(html);
                    });
                }

                function update(edu_id) {

                    api = $.dialog({
                        id: 'testID2',
                        lock: true,
                        padding: 0,
                        fixed: true,
                        title: "编辑",
                        width: 480,
                        height: 420,
                        max: false,
                        min: false
                    });
                    $.get('/school/default/update', {edu_id: edu_id,time:new Date()}, function(html) {
                        api.content(html);
                    });
                }
		$(function() {
                    $(".checkboxs").click(function() {
                        var checkedS = $(this).attr("checked");
                        if (checkedS) {
                            $(".checkbox").attr("checked", true)
                        } else {
                            $(".checkbox").removeAttr("checked")
                        }
                    })

                })
</script>